#include "BackgroundImageStrategy.h"
#include "ImageLoading.h"

#include <LDF/VisComponent.h>
#include <string>
#include <windows.h>
#include <GL/gl.h>


BackgroundImageStrategy::BackgroundImageStrategy(std::string imageName): VisComponentStrategy()
{
	imageLoader = new ImageLoading();
	imageTex = imageLoader->loadImageForTexture(imageName.c_str());
}

BackgroundImageStrategy::~BackgroundImageStrategy()
{
	delete imageLoader;
}

void BackgroundImageStrategy::draw(const std::vector<unsigned long> &selectedIds)
{
	float w2 = component->getWidth() / 2.0f;
	float h2 = component->getHeight() / 2.0f;

	glEnable(GL_TEXTURE_2D);	
		glColor3f(1.0, 1.0, 1.0);
		glBindTexture(GL_TEXTURE_2D, imageTex);
		glBegin(GL_QUADS);
			glTexCoord2f(0,0);
			glVertex3f(-w2,-h2,0);
			glTexCoord2f(1,0);
			glVertex3f(w2,-h2,0);
			glTexCoord2f(1,1);
			glVertex3f(w2,h2,0);
			glTexCoord2f(0,1);
			glVertex3f(-w2, h2,0);
		glEnd();
	glDisable(GL_TEXTURE_2D);
	glFlush();
}

void BackgroundImageStrategy::drawForPicking()
{
}

